forum

home / developersection / forums / writing events to log text file using java

Writing events to log text file using java

Kate Smith 2009 05-Oct-2013

The below line of code I am trying to write the events in a log file but no file is being created and I am also not getting any kind of error at all.

My log class:

public class Logs {

static FileHandler fileTxt;
static SimpleFormatter formatterTxt;
static public void logging() throws IOException {
    Logger logger = Logger.getLogger("");
    logger.setLevel(Level.INFO);
    fileTxt = new FileHandler("c:/SimleTaskEvents.txt");
    formatterTxt = new SimpleFormatter();
    fileTxt.setFormatter(formatterTxt);
    logger.addHandler(fileTxt);
}
}



Updated on 05-Oct-2013
Can you answer this question?

Answer

1 Answers

Liked By